<?php
//快速排序
function partition(&$array,$low,$high){
    $pivotkey=$array[$low];
    while($low<$high){
        while($low<$high&&$array[$high]>$pivotkey){
            $high--;
        }
        $array[$low]=$array[$high];

        while($low<$high&&$array[$low]<$pivotkey){
            $low++;
        }
        $array[$high]=$array[$low];
    }
    $array[$low]=$pivotkey;
    return $low;
}

function quickSort(&$array,$low,$high){
    if($low<$high){
        $mid=partition($array,$low,$high);
        quickSort($array,$low,$mid-1);
        QuickSort($array,$mid+1,$high);
    }
}

function Qsort(&$array){
    quickSort($array,0,count($array)-1);
}

$array=array(3,5,8,6,4,0,7,9,1,2);
Qsort($array);
print_r($array);
?>
